package shark.user.spi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import shark.user.spi.entity.SysRole;

import java.util.List;

@Mapper
public interface SysRoleMapper extends BaseMapper<SysRole> {
    @Delete("delete from sys_user_role where role_id = #{roleId}")
    void deleteRoleUser(@Param("roleId") String roleId);

    @Select("select * from sys_role where id in (select role_id from sys_user_role where user_id = #{userId})")
    List<SysRole> getRolesByUserId(@Param("userId") String userId);
}
